<?php
/*
 * This template does not output anything but a specific partial output
 */

// do nothing, if we do not have a standard resource query from ontowiki ...
if (!isset($this->resourceUri)) {
    return;
}

$resource = new OntoWiki_Resource($this->resourceUri, OntoWiki::getInstance()->selectedModel);
$fullDescription = $resource->getDescription();
$description = $fullDescription[$this->resourceUri];
$descriptionHelper = $resource->getDescriptionHelper();

// this is the standard template data
$templateData = array(
    'title'             => $descriptionHelper->getTitle($this->resourceUri),
    'resourceUri'       => $this->resourceUri,
    'description'       => $description,
    'descriptionHelper' => $descriptionHelper, 
    'options'           => isset($this->options) ? $this->options : array()
);

if (isset($description['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) {
    $types = array ();
    foreach ($description['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'] as $property) {
        if ((isset($property['value'])) && (Erfurt_Uri::check($property['value']))) {
            $types[$property['value']] = true;
        }
    }

    switch (true) {
        case (isset($types['http://lod2.eu/schema/Testimonial'])):
            echo $this->partial('lod2/items/testimonial.phtml', $templateData);
            break;
        case (isset($types['http://lod2.eu/schema/Demo'])):
            echo $this->partial('lod2/items/demo.phtml', $templateData);
            break;
        case (isset($types['http://rdfs.org/sioc/types#WikiArticle'])):
        case (isset($types['http://rdfs.org/sioc/ns#Post'])):
        case (isset($types['http://usefulinc.com/ns/doap#Project'])):
        case (isset($types['http://lod2.eu/schema/Partner'])):
        case (isset($types['http://xmlns.com/foaf/0.1/Organization'])):
        case (isset($types['http://xmlns.com/foaf/0.1/Person'])):
        default:
            // no specific template found
            echo str_replace(array('<h3>', '</h3>'), array('<h4>', '</h4>'), $this->partial( 'lod2/items/abstract.phtml', $templateData));
            break;
    }
}
?>
